package com.ezandroid.library.image.ext.core.display;

import android.graphics.Bitmap;

import com.ezandroid.library.image.ext.core.display.blur.BlurProcess;
import com.ezandroid.library.image.ext.core.display.blur.NativeBlurProcess;
import com.nostra13.universalimageloader.core.assist.LoadedFrom;
import com.nostra13.universalimageloader.core.imageaware.ImageAware;

public class RoundedVignetteBlurBitmapDisplayer extends RoundedVignetteBitmapDisplayer {

    private final int depth;

    public RoundedVignetteBlurBitmapDisplayer(int cornerRadiusPixels, int depth) {
        super(cornerRadiusPixels);
        this.depth = depth;
    }

    public RoundedVignetteBlurBitmapDisplayer(int cornerRadiusPixels, int marginPixels, int depth) {
        super(cornerRadiusPixels, marginPixels);
        this.depth = depth;
    }

    @Override
    public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
        BlurProcess blurProcess = new NativeBlurProcess();
        Bitmap blurBitmap = blurProcess.blur(bitmap, depth);
        if (blurBitmap != null && !blurBitmap.isRecycled()) {
            imageAware.setImageDrawable(new RoundedVignetteDrawable(blurBitmap, cornerRadius,
                    margin));
        }
    }
}
